<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索</title>
    <link rel="stylesheet" href="./css/reset.css">
    <style>
        #app {
            width: 300px;
            height: 400px;
            border: 1px solid gainsboro;
            border-radius: 5px;
            margin: 100px auto;
            padding: 10px 20px;
        }

        .input_box {
            height: 40px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        input {
            width: 200px;
            height: 30px;
            border: 1px solid gainsboro;
            border-radius: 20px;
            padding: 0 10px;
            background-color: rgba(220, 220, 220, 0.353);
        }

        .find {
            color: rgb(3, 143, 224);
            cursor: pointer;
        }

        p {
            width: 100%;
            font-weight: 700;
            margin: 10px 5px;
        }

        .item,
        .task {
            display: inline-block;
            font-size: 14px;
            padding: 5px;
            background-color: rgba(220, 220, 220, 0.353);
            margin: 5px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="input_box">
            <input type="text" placeholder="搜索商家、商品名称" v-model="inputText">
            <div class="find" @click="find">搜索</div>
        </div>
        <div class="history">
            <p>历史搜索</p>
            <span class="item" v-for="(item,index) in historyList" v-bind:key="index">{{item}}</span>
        </div>
        <div class="found">
            <p>搜索发现</p>
            <span class="task" v-for="(item,index) in tasklist" v-bind:key="index">{{item}}</span>
        </div>
    </div>
</body>

</html>
<script src="./js/vue-2.5.21.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: {
            inputText: '',
            tasklist: ['麻辣烫', '米线', '披萨', '蛋糕', '汉堡', '腊八粥', '烤肉拌饭', '炸鸡', '味多美'],
            historyList: ['天天鲜挪威三文鱼(立水桥店)']
        },
        methods: {
            find() {
                if (this.inputText) {
                    this.historyList.push(this.inputText)
                    this.inputText = ''
                }
            }
        }
    })
</script>